Ext.define('Usws.controller.Launch', {
    extend: 'Ext.app.Controller',
    refs: [
           {
               ref: 'navigation',
               selector: 'navigation'
           },
   		   {
               ref: 'contentPanel',
               selector: 'contentPanel'
           }
    ],

    init: function() {
        this.control({
            'navigation': {
            	itemclick: 'navClick'
            }
        });
    },

    navClick: function (view, record, item, index, e, eOpts ) {
    	checkIsLogin();
 	    var text = record.get('text'),
	        xtype = record.get('name'),
	        alias = 'widget.' + xtype+'-Grid',
	        contentPanel = this.getContentPanel(),
	        cmp;
	    if (record.get("leaf") && xtype) { // only leaf nodes have ids
	        contentPanel.removeAll(true);
	
	        var className = Ext.ClassManager.getNameByAlias(alias);
	        var ViewClass = Ext.ClassManager.get(className);
	        if(ViewClass) {
		        var clsProto = ViewClass.prototype;
		        if (clsProto.themes) {
		            clsProto.themeInfo = clsProto.themes[Ext.themeName] || clsProto.themes.classic;
		        }
		
		        cmp = new ViewClass();
		        contentPanel.add(cmp);
		      //  if (cmp.floating) {
		       //     cmp.show();
		       // }
		        document.title = document.title.split(' - ')[0] + ' - ' + text;
		        location.hash = xtype;
	        }
	    }
    }
});